Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USER command needs /etc/passwd, thus require the fs to be unpacked #508

Merged
merged 1 commit into from
Jan 9, 2019

Conversation

myers
Copy link
Contributor

@myers myers commented Jan 8, 2019

Currently if you try to build this Dockerfile:

FROM node
EXPOSE 8081
COPY server.js .
USER nobody
CMD node server.js

you get this error:

INFO[0003] USER nobody
INFO[0003] cmd: USER
error building image: error building stage: open /etc/passwd: no such file or directory 

We can fix this by unpacking the fs for this command.

@container-tools-bot
Copy link
Collaborator

Hi @myers. Thanks for your PR.

I'm waiting for a GoogleContainerTools member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@dlorenc dlorenc merged commit 1591f41 into GoogleContainerTools:master Jan 9, 2019
@myers myers deleted the user-should-unpack-fs branch January 9, 2019 13:46
@mcfedr
Copy link
Contributor

mcfedr commented Mar 4, 2019

Is this merged and fixed? I'm having the same problem,

INFO[0000] Downloading base image eu.gcr.io/my/base/image:latest
INFO[0001] Error while retrieving image from cache: geting file info: stat /cache/sha256:e42ff730b63a982a79bd680817ce3492b85d83577be1c544bfffcb18a9cde539: no such file or directory
INFO[0001] Downloading base image eu.gcr.io/my/base/image:latest
INFO[0003] cmd: USER
error building image: error building stage: open /etc/passwd: no such file or directory

My docker file uses build arg for the from, wondering if this is having an effect,

ARG from_base
FROM $from_base

USER www-data
...

@adaniline-traderev
Copy link

adaniline-traderev commented Mar 4, 2019

The problem still exists with cached layers:

FROM node:9.4.0-alpine
RUN addgroup -S appgroup && adduser -S appuser -G appgroup

WORKDIR /app
COPY ./package.json ./yarn.lock /app/

RUN ["yarn", "install", "--prod"]

COPY ./build/ /app/ 

EXPOSE 3001
USER appuser
ENTRYPOINT [ "node", "server.js" ]
�[36mINFO�[0m[0000] Downloading base image node:9.4.0-alpine     
2019/03/04 14:51:54 No matching credentials were found, falling back on anonymous
�[36mINFO�[0m[0000] Error while retrieving image from cache: getting file info: stat /cache/sha256:359a2efa481b9edeff9ca120128f89387ce13dafe30b05f762ec63c7f770e415: no such file or directory 
�[36mINFO�[0m[0000] Downloading base image node:9.4.0-alpine     
2019/03/04 14:51:54 No matching credentials were found, falling back on anonymous
�[36mINFO�[0m[0000] Executing 0 build triggers                   
�[36mINFO�[0m[0000] Checking for cached layer [snip]/cache:e89ade091d2829d64cb1757f0beda3704a30463ca56d47755ce6b2184f088d16... 
�[36mINFO�[0m[0000] Using caching version of cmd: RUN addgroup -S appgroup && adduser -S appuser -G appgroup 
[---snip---]�
�[36mINFO�[0m[0000] cmd: EXPOSE                                  
�[36mINFO�[0m[0000] Adding exposed port: 3001/tcp                
�[36mINFO�[0m[0000] cmd: USER                                    
error building image: error building stage: open /etc/passwd: no such file or directory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants